package com.hivekion.system.controller;

import com.hivekion.common.entity.TreeNode;
import com.hivekion.system.domain.vo.BaseAreaCreateInputVo;
import com.hivekion.system.domain.vo.BaseAreaModelVo;
import com.hivekion.system.domain.vo.BaseAreaUpdateInputVo;
import com.hivekion.system.domain.vo.BaseAreaViewVo;
import com.hivekion.system.service.IBaseAreaService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/baseArea")
public class BaseAreaController {
    @Autowired
    IBaseAreaService service;

    @GetMapping("/getList")
    public List<BaseAreaViewVo> getList(String parentId) {
        return service.getAreaList(parentId);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody BaseAreaCreateInputVo vo) {
        return service.add(vo);
    }

    @PutMapping("/edit")
    public boolean edit(@RequestBody BaseAreaUpdateInputVo vo) {
        return service.edit(vo);
    }

    @DeleteMapping("/removeBaseArea")
    public boolean remove(String id) {
        return service.remove(id);
    }

    @GetMapping("/getInfo")
    public BaseAreaModelVo getInfo(String key) {
        return service.getInfo(key);
    }

    @GetMapping("/getTreeNodes")
    @ApiOperation(value = "获取所有区域", notes = "行政区域管理")
    public List<TreeNode> getTreeNodes() {
        return service.getTreeNodes();
    }
}
